<%
var headerPart = {
%>
<script type="text/javascript">
    $(document).ready(function() {
        $("#btnExport").click(function(){
            layer.confirm('确认要导出用户数据吗？', {
                btn: ['确定','取消'] //按钮
            }, function(index){
                layer.close(index);
                $("#searchForm").attr("action","${ctx}/sys/user/export");
                $("#searchForm").submit();
            }, function(index){
                layer.close(index);
            });
        });
        $("#btnImport").click(function(){
            layer.open({
                type: 1,
                title: '导入数据',
                area: ['400px', '230px'], //宽高
                content: $("#importBox").html(),
                btn:['关闭']
            });
        });
    });
    function page(n,s){
        if(n) $("#pageNo").val(n);
        if(s) $("#pageSize").val(s);
        $("#searchForm").attr("action","${ctx}/sys/user/list");
        $("#searchForm").submit();
        return false;
    }
</script>
<% }; %>
<% layout("/layouts/micro.html",{headerSection:headerPart}){ %>
<div class="layui-fluid" style="padding: 5px!important;">
	<div class="layui-card">
	<div id="importBox" style="display: none">
		<form id="importForm" action="${ctx}/sys/user/import" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onsubmit="layer.load(0, {shade: false});"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
			<a href="${ctx}/sys/user/import/template">下载模板</a>
		</form>
	</div>
	<!--
	<div class="layui-tab layui-tab-brief childrenBody">
	<ul class="layui-tab-title">
		<li class="layui-this"><a href="${ctx}/sys/user/list">用户列表</a></li>
		<%if(shiro.hasPermission("sys:user:edit")){%><li><a href="${ctx}/sys/user/form">用户添加</a></li><%}%>
	</ul>
 	<div class="layui-tab-content">-->
	<div class="layui-card-body">
		<#message content="${message!}"/>
		<%if(shiro.hasPermission("sys:user:edit")){%>
		<div>
			<button class="layui-btn layui-btn-normal LAY_ADD_user_btn"><i class="layui-icon layui-icon-add-1"></i>用户添加</button>
		</div>
		<%}%>
	
	<table  id="contentTable" class="layui-table" >
		<thead><tr><th>归属公司</th><th>归属部门</th><th class="sort-column login_name">登录名</th><th class="sort-column name">姓名</th><th>电话</th><th>手机</th><%if(shiro.hasPermission("sys:user:edit")){%><th>操作</th><%}%></tr></thead>
		<tbody>
			<%for(user in page.list){%>
			<tr>
				<td>${user.company.name}</td>
				<td>${user.office.name}</td>
				<td><a href="${ctx}/sys/user/form?id=${user.id}">${user.loginName}</a></td>
				<td>${user.name}</td>
				<td>${user.phone}</td>
				<td>${user.mobile}</td>
				<%if(shiro.hasPermission("sys:user:edit")){%>
				<td>
    				<a class="layui-btn layui-btn-xs" onclick="editUser('${user.id}')" href="javascript:void(0);">修改</a>
					<a class="layui-btn layui-btn-danger layui-btn-xs" href="${ctx}/sys/user/delete?id=${user.id}" onclick="return confirmx('确认要删除该用户吗？', this.href)">删除</a>
				</td>
				<%}%>
			</tr>
			<%}%>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	</div>
</div>
</div>
<script>
    layui.use(['form','layer'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;
        //添加
        $(".LAY_ADD_user_btn").click(function(){
            var index = layui.layer.open({
                title : "添加用户",
                type : 2,
                content : "${ctx}/sys/user/form",
                maxmin: true,
                area: ['900px', '600px'],
                btn: ['确定', '取消'],
                yes: function(index, layero){
                    var submit = layero.find('iframe').contents().find('#userForm');
                    submit.trigger('click');
                    layer.close(index);
                },
                end:function(){
                    location.reload();
                }
            })
        })
    })
    var editUser = function(id){
        var index = layui.layer.open({
            title : "修改用户",
            type : 2,
            content : "${ctx}/sys/user/form?id="+id,
            maxmin: true,
            area: ['900px', '600px'],
            btn: ['确定', '取消'],
            yes: function(index, layero){
                var submit = layero.find('iframe').contents().find('#userForm');
                submit.trigger('click');
                layer.close(index);
            },
            end:function(){
                location.reload();
            }
        })
    }
</script>
<%}%>